Skip to content

Expose IsSticky() on SlotReservationInfo for sticky queue awareness#2193

Open
billrich2001 wants to merge 5 commits intomainfrom
feat/expose-sticky-to-slot-supplier
Open

Expose IsSticky() on SlotReservationInfo for sticky queue awareness#2193
billrich2001 wants to merge 5 commits intomainfrom
feat/expose-sticky-to-slot-supplier

Conversation

@billrich2001
Copy link
Copy Markdown

Summary

  • Adds IsSticky() bool to the SlotReservationInfo interface so that custom SlotSupplier implementations can distinguish sticky vs normal workflow task queue polls at slot reservation time.
  • For mixed-mode pollers (the default), the sticky/normal decision is moved before ReserveSlot so IsSticky() is accurate for all poller configurations.
  • For activity, local activity, and nexus slots, IsSticky() always returns false.

Fixes #2191

Approach

Commit 1 -- Add IsSticky() to the public interface:

  • Extends SlotReservationInfo with IsSticky() bool
  • Propagates isSticky through slotReservationData and trackingSlotSupplier
  • Sets the flag based on poller mode in runPoller

Commit 2 -- Make IsSticky() accurate for mixed-mode pollers:

  • Introduces a pollHint struct to carry a pre-decided sticky/normal choice
  • Adds decideNextPollKind() on workflowTaskPoller which commits to sticky vs normal before slot reservation (using the same backlog/pending-count balancing logic)
  • Modifies getNextPollRequest() to honor the pre-decided hint, skipping the inline re-decision
  • Threads the hint through taskPoller.PollTask() -> poll() -> getNextPollRequest()
  • Handles cancellation: undoPollDecision() reverses the counter increment if reservation fails or is cancelled
  • Expands test coverage with 12 new tests for counter lifecycle, hint propagation, and all poller modes

Test plan

  • All 298 existing internal package tests pass
  • New unit tests for decideNextPollKind() across all modes (Sticky, NonSticky, Mixed with balancing, backlog, disabled cache)
  • New unit tests for undoPollDecision() (Mixed and non-Mixed)
  • New unit tests for getNextPollRequest() with and without hint
  • Counter lifecycle tests (happy path: decide -> poll -> release; cancel path: decide -> fail -> undo)
  • go vet and linter clean

Made with Cursor

@billrich2001 billrich2001 requested a review from a team as a code owner February 13, 2026 22:33
billrich2001 and others added 4 commits February 13, 2026 16:08
Expose a boolean on SlotReservationInfo so that custom SlotSupplier
implementations can know whether a slot reservation is for a sticky
workflow task queue poll. This brings the Go SDK in line with other
Temporal SDKs (fixes #2191).

For dedicated Sticky-mode pollers the flag is accurate. For mixed-mode
pollers (the default) the flag returns false because the sticky-vs-normal
decision is made after slot reservation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move the sticky/normal poll decision before slot reservation so that
SlotSupplier.ReserveSlot receives an accurate IsSticky() value even
when the worker uses a mixed-mode poller (the default for non-autoscaling
workers).

Key changes:
- Add pollHint struct to carry pre-decided sticky/normal choice
- Add decideNextPollKind() / undoPollDecision() on workflowTaskPoller
- Modify getNextPollRequest() to accept a *pollHint and skip inline
  re-decision when a hint is provided
- Thread the hint through taskPoller.PollTask -> poll -> getNextPollRequest
- Handle cancellation cleanup (undo counters if reservation fails)
- Expand test coverage for counter lifecycle and hint propagation

Co-authored-by: Cursor <cursoragent@cursor.com>
Update PollTask signature on the test mock to accept *pollHint,
matching the interface change from the previous commit.

Co-authored-by: Cursor <cursoragent@cursor.com>
@billrich2001 billrich2001 force-pushed the feat/expose-sticky-to-slot-supplier branch from d635ac7 to 8e4ec8b Compare February 13, 2026 23:16
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stupid AI did a push --force-with-lease including this nonsense from something unrelated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose whether a task queue is sticky to slot supplier.

1 participant